//后端配置静态资源映射
package com.course02.order_backend.config.Ost;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    // 头像上传目录
    private final String AVATAR_DIR = "D:/order_upload/avatars/";

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射上传的头像资源
        registry.addResourceHandler("/upload/avatars/**")
                .addResourceLocations("file:" + AVATAR_DIR);
    }
}